R/2_visualization.r
radial_cheem_tour.RdCreate a linked plotlyof the global data-
and attribution- spaces. Typically consumed directly by shiny app.
radial_cheem_tour(
cheem_ls,
basis,
manip_var,
primary_obs = NULL,
comparison_obs = NULL,
do_add_pcp_segments = TRUE,
pcp_shape = c(3, 142, 124),
angle = 0.15,
row_index = NULL,
inc_var_nms = NULL,
do_center_frame = TRUE,
do_add_residual = FALSE
)
radial_cheem_tour_subplots(
cheem_ls,
basis,
manip_var,
primary_obs = NULL,
comparison_obs = NULL,
do_add_pcp_segments = TRUE,
pcp_shape = c(3, 142, 124),
angle = 0.15,
row_index = NULL,
inc_var_nms = NULL,
do_center_frame = TRUE
)A return from cheem_ls(), a list of data frames.
A 1D projection basis, typically a return of
basis_attr_df().
The , number of the manipulation variable.
The rownumber of the primary observation. Its local attribution becomes the 1d projection basis, and the point it highlighted as a dashed line. Defaults to NULL, no primary observation highlighted.
The rownumber of the comparison observation. Point is highlighted as a dotted line. Defaults to NULL, no comparison observation highlighted.
Logical, whether or not to add parallel coordinate line segments to the basis display.
The number of the shape character to add. Expects
3, 142, or 124, '+', '|' in plotly, and '|' in gganimate, respectively.
Defaults to 3, '+' in either output.
The step size between interpolated frames, in radians. Defaults to .15.
Numeric index of selected observations. Defaults to TRUE; 1:n.
A vector of the names of the variables to include in the projection.
Whether or not to scale by standard deviations away from the mean within each frame or not. Defaults to TRUE, helping to keep the animation centered.
Whether of not to add a facet with a fixed y on residual. Doing so may cause issues with animation. Defaults to FALSE.
ggtour (ggplot2 object with frame info) animation frames of a
radial tour manipulating the contribution of a selected tour. Animated with
spinifex::animate_* functions.
Other cheem consumers:
global_view(),
run_app()
library(cheem)
library(spinifex)
## Classification:
X <- penguins_na.rm[, 1:4]
clas <- penguins_na.rm$species
Y <- as.integer(clas)
rf_fit <- default_rf(X, Y)
## Long runtime for full datasets or complex models:
shap_df <- attr_df_treeshap(rf_fit, X, noisy = FALSE)
#>
|0%----|------|20%---|------|40%---|------|60%---|------|80%---|------|100%
#> =---------------------------------------------------------------------- (0%)
=---------------------------------------------------------------------- (0%)
=---------------------------------------------------------------------- (0%)
=---------------------------------------------------------------------- (0%)
=---------------------------------------------------------------------- (1%)
==--------------------------------------------------------------------- (1%)
==--------------------------------------------------------------------- (1%)
==--------------------------------------------------------------------- (2%)
==--------------------------------------------------------------------- (2%)
==--------------------------------------------------------------------- (2%)
===-------------------------------------------------------------------- (3%)
===-------------------------------------------------------------------- (3%)
===-------------------------------------------------------------------- (3%)
===-------------------------------------------------------------------- (3%)
===-------------------------------------------------------------------- (4%)
====------------------------------------------------------------------- (4%)
====------------------------------------------------------------------- (4%)
====------------------------------------------------------------------- (5%)
====------------------------------------------------------------------- (5%)
====------------------------------------------------------------------- (5%)
=====------------------------------------------------------------------ (6%)
=====------------------------------------------------------------------ (6%)
=====------------------------------------------------------------------ (6%)
=====------------------------------------------------------------------ (6%)
======----------------------------------------------------------------- (7%)
======----------------------------------------------------------------- (7%)
======----------------------------------------------------------------- (7%)
======----------------------------------------------------------------- (8%)
======----------------------------------------------------------------- (8%)
=======---------------------------------------------------------------- (8%)
=======---------------------------------------------------------------- (9%)
=======---------------------------------------------------------------- (9%)
=======---------------------------------------------------------------- (9%)
=======---------------------------------------------------------------- (9%)
========--------------------------------------------------------------- (10%)
========--------------------------------------------------------------- (10%)
========--------------------------------------------------------------- (10%)
========--------------------------------------------------------------- (11%)
========--------------------------------------------------------------- (11%)
=========-------------------------------------------------------------- (11%)
=========-------------------------------------------------------------- (12%)
=========-------------------------------------------------------------- (12%)
=========-------------------------------------------------------------- (12%)
==========------------------------------------------------------------- (12%)
==========------------------------------------------------------------- (13%)
==========------------------------------------------------------------- (13%)
==========------------------------------------------------------------- (13%)
==========------------------------------------------------------------- (14%)
===========------------------------------------------------------------ (14%)
===========------------------------------------------------------------ (14%)
===========------------------------------------------------------------ (15%)
===========------------------------------------------------------------ (15%)
===========------------------------------------------------------------ (15%)
============----------------------------------------------------------- (15%)
============----------------------------------------------------------- (16%)
============----------------------------------------------------------- (16%)
============----------------------------------------------------------- (16%)
============----------------------------------------------------------- (17%)
=============---------------------------------------------------------- (17%)
=============---------------------------------------------------------- (17%)
=============---------------------------------------------------------- (18%)
=============---------------------------------------------------------- (18%)
==============--------------------------------------------------------- (18%)
==============--------------------------------------------------------- (18%)
==============--------------------------------------------------------- (19%)
==============--------------------------------------------------------- (19%)
==============--------------------------------------------------------- (19%)
===============-------------------------------------------------------- (20%)
===============-------------------------------------------------------- (20%)
===============-------------------------------------------------------- (20%)
===============-------------------------------------------------------- (21%)
===============-------------------------------------------------------- (21%)
================------------------------------------------------------- (21%)
================------------------------------------------------------- (21%)
================------------------------------------------------------- (22%)
================------------------------------------------------------- (22%)
================------------------------------------------------------- (22%)
=================------------------------------------------------------ (23%)
=================------------------------------------------------------ (23%)
=================------------------------------------------------------ (23%)
=================------------------------------------------------------ (24%)
==================----------------------------------------------------- (24%)
==================----------------------------------------------------- (24%)
==================----------------------------------------------------- (24%)
==================----------------------------------------------------- (25%)
==================----------------------------------------------------- (25%)
===================---------------------------------------------------- (25%)
===================---------------------------------------------------- (26%)
===================---------------------------------------------------- (26%)
===================---------------------------------------------------- (26%)
===================---------------------------------------------------- (27%)
====================--------------------------------------------------- (27%)
====================--------------------------------------------------- (27%)
====================--------------------------------------------------- (27%)
====================--------------------------------------------------- (28%)
====================--------------------------------------------------- (28%)
=====================-------------------------------------------------- (28%)
=====================-------------------------------------------------- (29%)
=====================-------------------------------------------------- (29%)
=====================-------------------------------------------------- (29%)
======================------------------------------------------------- (30%)
======================------------------------------------------------- (30%)
======================------------------------------------------------- (30%)
======================------------------------------------------------- (30%)
======================------------------------------------------------- (31%)
=======================------------------------------------------------ (31%)
=======================------------------------------------------------ (31%)
=======================------------------------------------------------ (32%)
=======================------------------------------------------------ (32%)
=======================------------------------------------------------ (32%)
========================----------------------------------------------- (33%)
========================----------------------------------------------- (33%)
========================----------------------------------------------- (33%)
========================----------------------------------------------- (33%)
========================----------------------------------------------- (34%)
=========================---------------------------------------------- (34%)
=========================---------------------------------------------- (34%)
=========================---------------------------------------------- (35%)
=========================---------------------------------------------- (35%)
==========================--------------------------------------------- (35%)
==========================--------------------------------------------- (36%)
==========================--------------------------------------------- (36%)
==========================--------------------------------------------- (36%)
==========================--------------------------------------------- (36%)
===========================-------------------------------------------- (37%)
===========================-------------------------------------------- (37%)
===========================-------------------------------------------- (37%)
===========================-------------------------------------------- (38%)
===========================-------------------------------------------- (38%)
============================------------------------------------------- (38%)
============================------------------------------------------- (39%)
============================------------------------------------------- (39%)
============================------------------------------------------- (39%)
============================------------------------------------------- (39%)
=============================------------------------------------------ (40%)
=============================------------------------------------------ (40%)
=============================------------------------------------------ (40%)
=============================------------------------------------------ (41%)
==============================----------------------------------------- (41%)
==============================----------------------------------------- (41%)
==============================----------------------------------------- (42%)
==============================----------------------------------------- (42%)
==============================----------------------------------------- (42%)
===============================---------------------------------------- (42%)
===============================---------------------------------------- (43%)
===============================---------------------------------------- (43%)
===============================---------------------------------------- (43%)
===============================---------------------------------------- (44%)
================================--------------------------------------- (44%)
================================--------------------------------------- (44%)
================================--------------------------------------- (45%)
================================--------------------------------------- (45%)
================================--------------------------------------- (45%)
=================================-------------------------------------- (45%)
=================================-------------------------------------- (46%)
=================================-------------------------------------- (46%)
=================================-------------------------------------- (46%)
==================================------------------------------------- (47%)
==================================------------------------------------- (47%)
==================================------------------------------------- (47%)
==================================------------------------------------- (48%)
==================================------------------------------------- (48%)
===================================------------------------------------ (48%)
===================================------------------------------------ (48%)
===================================------------------------------------ (49%)
===================================------------------------------------ (49%)
===================================------------------------------------ (49%)
====================================----------------------------------- (50%)
====================================----------------------------------- (50%)
====================================----------------------------------- (50%)
====================================----------------------------------- (51%)
====================================----------------------------------- (51%)
=====================================---------------------------------- (51%)
=====================================---------------------------------- (51%)
=====================================---------------------------------- (52%)
=====================================---------------------------------- (52%)
=====================================---------------------------------- (52%)
======================================--------------------------------- (53%)
======================================--------------------------------- (53%)
======================================--------------------------------- (53%)
======================================--------------------------------- (54%)
=======================================-------------------------------- (54%)
=======================================-------------------------------- (54%)
=======================================-------------------------------- (54%)
=======================================-------------------------------- (55%)
=======================================-------------------------------- (55%)
========================================------------------------------- (55%)
========================================------------------------------- (56%)
========================================------------------------------- (56%)
========================================------------------------------- (56%)
========================================------------------------------- (57%)
=========================================------------------------------ (57%)
=========================================------------------------------ (57%)
=========================================------------------------------ (57%)
=========================================------------------------------ (58%)
=========================================------------------------------ (58%)
==========================================----------------------------- (58%)
==========================================----------------------------- (59%)
==========================================----------------------------- (59%)
==========================================----------------------------- (59%)
===========================================---------------------------- (60%)
===========================================---------------------------- (60%)
===========================================---------------------------- (60%)
===========================================---------------------------- (60%)
===========================================---------------------------- (61%)
============================================--------------------------- (61%)
============================================--------------------------- (61%)
============================================--------------------------- (62%)
============================================--------------------------- (62%)
============================================--------------------------- (62%)
=============================================-------------------------- (63%)
=============================================-------------------------- (63%)
=============================================-------------------------- (63%)
=============================================-------------------------- (63%)
=============================================-------------------------- (64%)
==============================================------------------------- (64%)
==============================================------------------------- (64%)
==============================================------------------------- (65%)
==============================================------------------------- (65%)
===============================================------------------------ (65%)
===============================================------------------------ (66%)
===============================================------------------------ (66%)
===============================================------------------------ (66%)
===============================================------------------------ (66%)
================================================----------------------- (67%)
================================================----------------------- (67%)
================================================----------------------- (67%)
================================================----------------------- (68%)
================================================----------------------- (68%)
=================================================---------------------- (68%)
=================================================---------------------- (69%)
=================================================---------------------- (69%)
=================================================---------------------- (69%)
=================================================---------------------- (69%)
==================================================--------------------- (70%)
==================================================--------------------- (70%)
==================================================--------------------- (70%)
==================================================--------------------- (71%)
===================================================-------------------- (71%)
===================================================-------------------- (71%)
===================================================-------------------- (72%)
===================================================-------------------- (72%)
===================================================-------------------- (72%)
====================================================------------------- (72%)
====================================================------------------- (73%)
====================================================------------------- (73%)
====================================================------------------- (73%)
====================================================------------------- (74%)
=====================================================------------------ (74%)
=====================================================------------------ (74%)
=====================================================------------------ (75%)
=====================================================------------------ (75%)
=====================================================------------------ (75%)
======================================================----------------- (75%)
======================================================----------------- (76%)
======================================================----------------- (76%)
======================================================----------------- (76%)
=======================================================---------------- (77%)
=======================================================---------------- (77%)
=======================================================---------------- (77%)
=======================================================---------------- (78%)
=======================================================---------------- (78%)
========================================================--------------- (78%)
========================================================--------------- (78%)
========================================================--------------- (79%)
========================================================--------------- (79%)
========================================================--------------- (79%)
=========================================================-------------- (80%)
=========================================================-------------- (80%)
=========================================================-------------- (80%)
=========================================================-------------- (81%)
=========================================================-------------- (81%)
==========================================================------------- (81%)
==========================================================------------- (81%)
==========================================================------------- (82%)
==========================================================------------- (82%)
===========================================================------------ (82%)
===========================================================------------ (83%)
===========================================================------------ (83%)
===========================================================------------ (83%)
===========================================================------------ (84%)
============================================================----------- (84%)
============================================================----------- (84%)
============================================================----------- (84%)
============================================================----------- (85%)
============================================================----------- (85%)
=============================================================---------- (85%)
=============================================================---------- (86%)
=============================================================---------- (86%)
=============================================================---------- (86%)
=============================================================---------- (87%)
==============================================================--------- (87%)
==============================================================--------- (87%)
==============================================================--------- (87%)
==============================================================--------- (88%)
===============================================================-------- (88%)
===============================================================-------- (88%)
===============================================================-------- (89%)
===============================================================-------- (89%)
===============================================================-------- (89%)
================================================================------- (90%)
================================================================------- (90%)
================================================================------- (90%)
================================================================------- (90%)
================================================================------- (91%)
=================================================================------ (91%)
=================================================================------ (91%)
=================================================================------ (92%)
=================================================================------ (92%)
=================================================================------ (92%)
==================================================================----- (93%)
==================================================================----- (93%)
==================================================================----- (93%)
==================================================================----- (93%)
===================================================================---- (94%)
===================================================================---- (94%)
===================================================================---- (94%)
===================================================================---- (95%)
===================================================================---- (95%)
====================================================================--- (95%)
====================================================================--- (96%)
====================================================================--- (96%)
====================================================================--- (96%)
====================================================================--- (96%)
=====================================================================-- (97%)
=====================================================================-- (97%)
=====================================================================-- (97%)
=====================================================================-- (98%)
=====================================================================-- (98%)
======================================================================- (98%)
======================================================================- (99%)
======================================================================- (99%)
======================================================================- (99%)
======================================================================= (100%)
this_ls <- cheem_ls(X, Y, class = clas,
model = rf_fit,
attr_df = shap_df)
bas <- basis_attr_df(shap_df, rownum = 1)
ggt <- radial_cheem_tour(this_ls, basis = bas, manip_var = 1,
primary_obs = 1, comparison_obs = 2)
#> Warning: ‘*’ not meaningful for factors
if (FALSE) {
animate_plotly(ggt)
if(FALSE) ## or animate with gganimate
animate_gganimate(ggt) #, render = gganimate::av_renderer())
## Regression:
dat <- amesHousing2018_NorthAmes
X <- dat[, 1:9]
Y <- log(dat$SalePrice)
clas <- dat$SubclassMS
rf_fit <- default_rf(X, Y)
## Long runtime for full datasets or complex models:
shap_df <- attr_df_treeshap(rf_fit, X, noisy = FALSE)
this_ls <- cheem_ls(X, Y, class = clas,
model = rf_fit,
attr_df = shap_df)
bas <- basis_attr_df(shap_df, rownum = 1)
ggt <- radial_cheem_tour(this_ls, basis = bas, manip_var = 1)
animate_plotly(ggt)
if(FALSE) ## or animate with gganimate
animate_gganimate(ggt, render = gganimate::av_renderer())
}
## Experimental radial tour made from plotly::subplots rather than facets
ggt <- radial_cheem_tour_subplots(this_ls, basis = bas, manip_var = 1)
#> Warning: ‘*’ not meaningful for factors
animate_plotly(ggt)